<?php
require_once 'ActionFramework/inputs.php';

class FloatInputTestCase extends PHPUnit_Framework_TestCase
{
    public function testVanilla()
    {
    	$input = new FloatInput('DUMMY_NAME', 'Dummy name');
    	
    	$result = $input->validate('');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    	$result = $input->validate('qleflq');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    	$result = $input->validate('0');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    	$result = $input->validate('1');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    	$result = $input->validate('-1');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    	$result = $input->validate('6.9283');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    	$result = $input->validate('-82736287364827366.9283');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    }
    
    public function testMin()
    {
    	$input = new FloatInput('DUMMY_NAME', 'Dummy name', 0);
    	
    	$result = $input->validate('');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    	$result = $input->validate('qleflq');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    	$result = $input->validate('0');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    	$result = $input->validate('1');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    	$result = $input->validate('-1');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    	$result = $input->validate('6.9283');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    	$result = $input->validate('-82736287364827366.9283');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    }
    
    public function testMax()
    {
    	$input = new FloatInput('DUMMY_NAME', 'Dummy name', null, 5);
    	
    	$result = $input->validate('');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    	$result = $input->validate('qleflq');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    	$result = $input->validate('0');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    	$result = $input->validate('1');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    	$result = $input->validate('-1');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    	$result = $input->validate('6.9283');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    	$result = $input->validate('-82736287364827366.9283');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    }
    
    public function testCombined()
    {
    	$input = new FloatInput('DUMMY_NAME', 'Dummy name', -1, 0);
    	
    	$result = $input->validate('');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    	$result = $input->validate('qleflq');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    	$result = $input->validate('0');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    	$result = $input->validate('1');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    	$result = $input->validate('-1');
    	$this->assertTrue($result['valid'], $result['message']);
    	
    	$result = $input->validate('6.9283');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    	$result = $input->validate('-82736287364827366.9283');
    	$this->assertFalse($result['valid'], $result['message']);
    	
    }
    
}